"""
交易 - 微信授权绑定相关模型
"""

from typing import Dict, Any, Optional
from jlpay.model.base import OrgBaseReq, BaseResponse


class AuthBindRequest(OrgBaseReq):
    """微信授权绑定请求"""
    
    API_URL = "/open/trans/authbind"
    
    def __init__(self):
        """初始化微信授权绑定请求"""
        super().__init__()
        self.mch_id = None  # 商户号
        self.pay_type = None  # 交易类型
        self.jsapi_path = None  # JSAPI支付授权目录
        self.sub_appid = None  # 公众账号ID
        self.mch_create_ip = None  # 终端IP
    
    def set_mch_id(self, mch_id: str):
        """设置商户号"""
        self.mch_id = mch_id
        return self
    
    def set_pay_type(self, pay_type: str):
        """设置交易类型"""
        self.pay_type = pay_type
        return self
    
    def set_jsapi_path(self, jsapi_path: str):
        """设置JSAPI支付授权目录"""
        self.jsapi_path = jsapi_path
        return self
    
    def set_sub_appid(self, sub_appid: str):
        """设置公众账号ID"""
        self.sub_appid = sub_appid
        return self
    
    def set_mch_create_ip(self, mch_create_ip: str):
        """设置终端IP"""
        self.mch_create_ip = mch_create_ip
        return self
    
    def to_dict(self) -> Dict[str, Any]:
        """转换为字典格式"""
        data = super().to_dict()
        data.update({
            'mch_id': self.mch_id,
            'pay_type': self.pay_type,
            'jsapi_path': self.jsapi_path,
            'sub_appid': self.sub_appid,
            'mch_create_ip': self.mch_create_ip
        })
        return data


class AuthBindResponse(BaseResponse):
    """微信授权绑定响应"""
    
    def __init__(self, response_dict=None):
        """
        初始化微信授权绑定响应
        
        Args:
            response_dict: 响应字典
        """
        super().__init__(response_dict)
        # 由于没有对应的 Response.java 文件，响应只包含 ret_code 和 ret_msg
    
    def to_dict(self) -> Dict[str, Any]:
        """转换为字典格式"""
        data = super().to_dict()
        return data 